﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Data.SqlClient;
using System.Data;

namespace WebService
{
    public class Tour
    {
        private String _maTour;
        private string _tenTour;
        private String _loaiTour;
        private int _soNgay;
        private int _soDem;
        private String _maDiaDiemBD;
        private String _maDiaDiemKT;
        private String _hangMayBay;
        private string _ngayThucHien;
        private bool _isVanChuyen;
        private bool _isKhachSan;
        private bool _isMayBay;
        private float _giaTour;
        private int _trangThai;
        private String _moTaLichTrinh;
        public String[] _listKS;
        public String[] _listVC;
        public String[] _listMB;


        public String MoTaLichTrinh
        {
            get { return _moTaLichTrinh; }
            set { _moTaLichTrinh = value; }
        }
        public String MaTour
        {
            get { return _maTour; }
            set { _maTour = value; }
        }
        public string TenTour 
        { 
            get { return _tenTour; } 
            set { _tenTour = value; } 
        }
        public String LoaiTour 
        { 
            get { return _loaiTour; } 
            set { _loaiTour = value; } 
        }
        public int SoNgay 
        { 
            get { return _soNgay; } 
            set { _soNgay = value; } 
        }
        public int SoDem 
        { 
            get { return _soDem; } 
            set { _soDem = value; } 
        }
        public String MaDiaDiemBD 
        { 
            get { return _maDiaDiemBD; } 
            set { _maDiaDiemBD = value; } 
        }
        public String MaDiaDiemKT 
        {
            get { return _maDiaDiemKT; }
            set { _maDiaDiemKT = value; } 
        }
        public String HangMayBay 
        { 
            get { return _hangMayBay; } 
            set { _hangMayBay = value; } 
        }
        public string NgayThucHien 
        { 
            get { return _ngayThucHien; } 
            set { _ngayThucHien = value; } 
        }
        public bool IsVanChuyen 
        { 
            get { return _isVanChuyen; } 
            set { _isVanChuyen = value; } 
        }
        public bool IsKhachSan 
        { 
            get { return _isKhachSan; } 
            set { _isKhachSan = value; } 
        }
        public bool IsMayBay 
        {
            get { return _isMayBay; } 
            set { _isMayBay = value; } 
        }
        public float GiaTour 
        {
            get { return _giaTour; } 
            set { _giaTour = value; } 
        }
        public int TrangThai 
        {
            get { return _trangThai; } 
            set { _trangThai = value; } 
        }
        public void setValue(int value)
        {
            
        }
        public void LayThongTin(String MaTour)
        {
            string query = "select * from TourDuLich where MaTour like '" + MaTour+"'";
            DataTable dt = DataProvider.excecuteQuery(query);
            this._maTour = dt.Rows[0]["MaTour"].ToString();
            this._loaiTour = dt.Rows[0]["LoaiTour"].ToString();
            this._tenTour = dt.Rows[0]["TenTour"].ToString();
            this._soNgay = (int)dt.Rows[0]["SoNgay"];
            this._soDem = (int)dt.Rows[0]["SoDem"];
            this._maDiaDiemBD = dt.Rows[0]["MaDiaDiemBD"].ToString();
            this._maDiaDiemKT = dt.Rows[0]["MaDiaDiemKT"].ToString();
            this._hangMayBay = dt.Rows[0]["HangMayBay"].ToString();
            this._ngayThucHien = dt.Rows[0]["NgayThucHien"].ToString();
            this._giaTour = float.Parse(dt.Rows[0]["GiaTour"].ToString());
            this._trangThai = (int)dt.Rows[0]["TrangThai"];
            this.IsKhachSan = (bool)dt.Rows[0]["IsKhachSan"];
            this.IsVanChuyen = (bool)dt.Rows[0]["IsVanChuyen"];
            this.IsMayBay = (bool)dt.Rows[0]["IsMayBay"];
            this.MoTaLichTrinh = dt.Rows[0]["MoTaLichTrinh"].ToString();
            if (this.IsKhachSan)
            {
                String ks = "select TenKS from KhachSan where MaKS in (select MaKS from KSTour where MaTour like '"+this.MaTour+"')";
                DataTable dt2 = DataProvider.excecuteQuery(ks);
                int n = dt2.Rows.Count;
                this._listKS = new String[n];
                for (int i = 0; i < n; i++)
                    this._listKS[i] = dt2.Rows[i]["TenKS"].ToString();

            }
            if (this.IsVanChuyen)
            {
                String vc = "select TenHangXe from HangXe where MaHangXe in (select MaNVC from NVCTour where MaTour like '" + this.MaTour + "')";
                DataTable dt2 = DataProvider.excecuteQuery(vc);
                int n = dt2.Rows.Count;
                this._listVC = new String[n];
                for (int i = 0; i < n; i++)
                    this._listVC[i] = dt2.Rows[i]["TenHangXe"].ToString();

            }
            if (this.IsMayBay)
            {
                String mb = "select TenHangMB from HangMB where MaHangMB in (select MaHMB from HMBTour where MaTour like '" + this.MaTour + "')";
                DataTable dt2 = DataProvider.excecuteQuery(mb);
                int n = dt2.Rows.Count;
                this._listMB = new String[n];
                for (int i = 0; i < n; i++)
                    this._listMB[i] = dt2.Rows[i]["TenHangMB"].ToString();

            }
        }
    }
}